<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Admin\LoginController;

use App\Http\Controllers\Admin\ORMController;
use App\Http\Controllers\Admin\CityController;
use App\Http\Controllers\Admin\UploadController;
use App\Http\Controllers\Admin\CardController;
use App\Http\Controllers\Admin\OrderController;
use App\Http\Controllers\Admin\ShopController;
use App\Http\Controllers\Admin\GoodsController;

use App\Http\Controllers\Web\RongshuController;

use App\Http\Controllers\Web\OrderController as WebOrder;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});


// 后台路由
Route::group(['prefix' => 'admin'], function() {
    Route::any('user/login',        [LoginController::class, 'login']);
    Route::any('user/register',     [LoginController::class, 'register']);
    Route::any('user/info',         [LoginController::class, 'getAuthUser']);
    Route::any('user/logout',       [LoginController::class, 'logout']);


    Route::group(['middleware' => ['token.user']], function () {
        Route::any('test/index',    [\App\Http\Controllers\Admin\TestController::class, 'index']);

        Route::any('orm/index',   [ORMController::class, 'index']);
        Route::any('orm/create',  [ORMController::class, 'create']);
        Route::any('orm/import',  [ORMController::class, 'import']);
        Route::any('orm/update',  [ORMController::class, 'update']);
        Route::any('orm/delete',  [ORMController::class, 'delete']);
        Route::any('orm/detail',  [ORMController::class, 'detail']);

        Route::any('city/index',  [CityController::class, 'index']);
        Route::any('city/region', [CityController::class, 'region']);
        Route::any('city/import', [CityController::class, 'import']);

        Route::any('upload/upload', [UploadController::class, 'upload']);

        Route::any('card/list',     [CardController::class, 'index']);

        Route::any('order/list',    [OrderController::class, 'index']);
        Route::any('order/confirm', [OrderController::class, 'confirm']);
        Route::any('order/finish',  [OrderController::class, 'finish']);
        Route::any('order/cancel',  [OrderController::class, 'cancel']);
        Route::any('order/update',  [OrderController::class, 'update']);

        Route::any('goods/delete',              [GoodsController::class, 'delete']);
        Route::any('goods/tongbu_tzl_goods',    [GoodsController::class, 'tongbu_tzl_goods']);
        Route::any('goods/select_tzl_goods',    [GoodsController::class, 'select_tzl_goods']);

        Route::any('shop/import',   [ShopController::class, 'import']);
    });
});


// 荣数平台接口
Route::group(['prefix' => 'sip', 'middleware' => ['request.log']], function() {
   Route::post('cities',        [RongshuController::class, 'cities']);
   Route::post('order/create',  [RongshuController::class, 'order_create']);
   Route::post('refund/check',  [RongshuController::class, 'refund_check']);
   Route::post('refund/apply',  [RongshuController::class, 'refund_apply']);
   Route::post('refund/confirm',[RongshuController::class, 'refund_confirm']);
});

// h5前端页面接口
Route::group(['prefix' => 'web'], function() {
   Route::post('order/detail',  [WebOrder::class, 'detail']);
   Route::post('order/cities',  [WebOrder::class, 'cities']);
   Route::post('order/shops',   [WebOrder::class, 'shops']);
   Route::post('order/shop',    [WebOrder::class, 'shop']);
   Route::post('order/add',         [WebOrder::class, 'add_order']);
   Route::post('order/verify',      [WebOrder::class, 'verify_add_order']);
   Route::post('order/get_orders',  [WebOrder::class, 'get_orders']);
   Route::post('order/get_user',    [WebOrder::class, 'getUser']);

   // 模拟页面
    Route::post('order/goodsList',      [WebOrder::class, 'goodsList']);
    Route::post('order/createOrder',    [WebOrder::class, 'createOrder']);

    Route::post('order/sip_notify',     [WebOrder::class, 'sip_notify']);
});

